package  com.sat.common.widget

import android.content.Context
import android.graphics.Rect
import android.os.Build
import android.view.View
import android.widget.PopupWindow

class BasePopupWindow : PopupWindow {
    constructor(context: Context?) : super(context) {}
    constructor(width: Int, height: Int) : super(width, height) {}

    override fun showAsDropDown(
        anchor: View,
        xoff: Int,
        yoff: Int
    ) {
        if (Build.VERSION.SDK_INT >= 24) {
            val visibleFrame = Rect()
            anchor.getGlobalVisibleRect(visibleFrame)
            val height =
                anchor.resources.displayMetrics.heightPixels - visibleFrame.bottom
            setHeight(height)
        }
        super.showAsDropDown(anchor, xoff, yoff)
    }
}